**Curtis RESTAT
**This do file generates the results found in Panel C of Table 2
**Change to directory where data and code were downloaded
**cd 


set matsize 1500
clear all
set more off

use cbp_st_table2,clear


do dataclean_table2.do

gen empweight2=emp if year==1998
bysort stateind:carryforward empweight2,replace

gen NBPstr="NBP" if NBP==1
replace NBPstr="west" if NBPstr==""
gen NBPind=NBPstr+naics

drop yeardum*
tab year,gen(yeardum)

gen trend=year-1997
qui tab fipstate,gen(STdum)
foreach var of varlist ind1-ind21 {
qui gen trend`var'=`var'*trend
}

foreach x of varlist STdum1-STdum49 {
qui gen trend`x'=`x'*trend
}

/* Generate Seperate NBP/West Trends by Industry*/
forvalues i = 1(1)21 {
  qui gen eindtrend`i' = trendind`i'*NBP
 }
forvalues i = 1(1)21 {
  qui gen windtrend`i' = trendind`i'*((NBP-1)^2)
 }
tostring NBP,replace
gen yearindreg=yearind+"_"+NBP


qui tab yearind,gen(yearinddum)
qui tab STyear, gen(STyeardum)
qui tab stateind, gen(stateinddum)

/* Defines RHS variables to be included in every regression*/
mac def rhs_vars "postxint intxNBP postxNBP  "


drop if inlist(fipstate,"38","27","19","55","23","33","50","26","01")

/*NBP Region Only*/
*Column 1
qui eststo:areg lemp postxNBPxint postxint intxNBP postxNBP yeardum* [aweight=empweight2],abs(stateind) rob cluster(NBPind)
*Column 2
qui eststo:areg lemp postxNBPxint postxint intxNBP postxNBP yearinddum* trendSTdum* [aweight=empweight2],abs(stateind) rob cluster(NBPind)
*Column 3
qui eststo:areg lemp postxNBPxint postxint intxNBP yearinddum* STyeardum* [aweight=empweight2],abs(stateind) rob cluster(NBPind)
*Column 4
qui eststo:areg lemp postxNBPxint postxint intxNBP postxNBP yeardum* windtrend* eindtrend*[aweight=empweight2],abs(stateind) rob cluster(NBPind)
*Column 5
qui eststo:areg lemp postxNBPxint postxint intxNBP postxNBP yearinddum* trendSTdum* windtrend* eindtrend*[aweight=empweight2],abs(stateind) rob cluster(NBPind)
*Column 6
qui eststo:areg lemp postxNBPxint postxint intxNBP yearinddum* STyeardum* windtrend* eindtrend*[aweight=empweight2],abs(stateind) rob cluster(NBPind)

outreg2 [est1 est2 est3 est4 est5 est6] using "table2c.tex",keep(postxNBPxint postxNBP) nocons replace

